class Create<%= model_classname %> < ActiveRecord::Migration
  def self.up
    create_table :<%= model.pluralize %> do |t|
<% columns.each do |c| -%>
<% if c.class.eql?(Array) && c.size > 1 -%>
<% if c.class.eql?(Array) && c.size > 2 -%>
<% opt = [] -%>
<% opt << ", :#{$1} => #{$2}" if c.detect{|e| e.match(/^(null)_(true|false)$/)} -%>
<% opt << ", :#{$1} => #{$2}" if c.detect{|e| e.match(/^(limit)_(\d+)$/)} -%>
<% opt << ", :#{$1} => #{$2}" if c.detect{|e| e.match(/^(precision)_(\d+)$/)} -%>
<% opt << ", :#{$1} => #{$2}" if c.detect{|e| e.match(/^(scale)_(\d+)$/)} -%>
<% opt << ", :#{$1} => '#{$2}'" if c.detect{|e| e.match(/^(default)_(.[^_|:]+)$/)} -%>
<% opt << ", :auto_increment => #{$1}" if c.detect{|e| e.match(/^autoincrement_(true|false)$/)} -%>
<%= " ".*(6) %>t.<%= c[1] %> :<%= c[0] %> <%= opt.join(" ") + "\n" if !opt.empty? -%>
<% else -%>
<%= " ".*(6) %>t.<%= c[1] %> :<%= c[0] %>
<% end -%>
<% end -%>
<% end -%>
<%= "\n" + " ".*(6) %>t.timestamps
    end
  end

  def self.down
    drop_table :<%= model.pluralize %>
  end
end
